{% macro render(m, mname, api, rootApi, ClassName) %}
{% set lb = "{" %}
{% set rb = "}" %}
{% set pathParams = m.parameters|getPathParams|sort %}

/**
 * {{ m.id }}
{% if m.description %}
 * @desc {{ m.description|oneLine|cleanComments|safe }}
{% endif %}
{% if m.fragment %}
 * @example
 * {{ m.fragment|safe }}
{% endif %}
 * @alias {{ m.id }}
 * @memberOf! {{ api.name }}({{ api.version }})
 *
 * @param {object{% if not m.parameterOrder and not m.request %}={% endif %}} params Parameters for request
{% if m.parameters %}
{% for pname, p in m.parameters|dictsort %}
 * @param {{ lb }}{{ p.type }}{% if not p.required %}={% endif %}{{ rb }} params.{{ pname|getSafeParamName }} {{ p.description|oneLine|cleanComments|safe }}
{% endfor %}
{% endif %}
{% if m.supportsMediaUpload %}
  {% if m.request %}
    * @param  {object} params.resource Media resource metadata
  {% endif %}
  * @param {object} params.media Media object
  * @param {string} params.media.mimeType Media mime-type
  * @param {string|object} params.media.body Media body contents
{% elif m.request %}
  {% if m.request.$ref %}
    * @param {{ lb }}{{ api.name }}({{ api.version }}).{{ m.request.$ref }}{{ rb }} params.resource Request body data
  {% else %}
    * @param {object} params.resource Request body data
  {% endif %}
{% endif %}
 * @param {object} [options] Optionally override request options, such as `url`, `method`, and `encoding`.
 * @param {callback} callback The callback that handles the response.
 * @return {object} Request object
 */
{{ mname }}(params?: Params${{ClassName}}${{mname|capitalize}}, options?: MethodOptions): AxiosPromise<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>;
{{ mname }}(params: Params${{ClassName}}${{mname|capitalize}}, options: MethodOptions|BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>, callback: BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>): void;
{{ mname }}(params: Params${{ClassName}}${{mname|capitalize}}, callback: BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>): void;
{{ mname }}(callback: BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>): void;
{{ mname }}(paramsOrCallback?: Params${{ClassName}}${{mname|capitalize}}|BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>, optionsOrCallback?: MethodOptions|BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>, callback?: BodyResponseCallback<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>): void|AxiosPromise<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}> {
  let params = (paramsOrCallback || {}) as Params${{ClassName}}${{mname|capitalize}};
  let options = (optionsOrCallback || {}) as MethodOptions;

  if (typeof paramsOrCallback === 'function') {
    callback = paramsOrCallback;
    params = {} as Params${{ClassName}}${{mname|capitalize}};
    options = {};
  }

  if (typeof optionsOrCallback === 'function') {
    callback = optionsOrCallback;
    options = {};
  }

  const rootUrl = options.rootUrl || {{ rootApi.rootUrl|buildurl|safe }};
  const parameters = {
    options: Object.assign({
      url: (rootUrl + {{ ('/' + rootApi.servicePath + m.path)|buildurl|safe }}).replace(/([^:]\/)\/+/g, '$1'),
      method: '{{ m.httpMethod }}'
    }, options),
    params,
    {% if m.mediaUpload.protocols.simple.path %}mediaUrl: (rootUrl + {{ ('/' + m.mediaUpload.protocols.simple.path)|buildurl|safe }}).replace(/([^:]\/)\/+/g, '$1'),{% endif %}
    requiredParams: [{% if m.parameterOrder.length %}'{{ m.parameterOrder|join("', '")|safe }}'{% endif %}],
    pathParams: [{% if pathParams.length %}'{{ pathParams|join("', '")|safe }}'{% endif %}],
    context: this.getRoot()
  };
  {% set responseType = "Schema$" + m.response.$ref|default() %}
  if (callback) {
    createAPIRequest<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>(parameters, callback);
  } else {
    return createAPIRequest<{{ ("Schema$"+m.response.$ref) if m.response.$ref else "void" }}>(parameters);
  }
}
{% endmacro %}
